package com.project.web.controller.sys;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.hibernate.criterion.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.project.web.controller.BaseController;
import com.project.entity.sys.SysConstant;
import com.project.service.sys.SysConstantService;


/**
 * UserController
 * @author weimingsen
 *
 */
@Controller
@RequestMapping("/sysConstant")
public class SysConstantController extends BaseController<SysConstant>{
	
	private static final Logger logger = LoggerFactory.getLogger(SysConstantController.class);
	
	@Autowired
	private SysConstantService sysConstantService;
	
	/**
	 * 列表
	 * @param model
	 * @param request
	 * @param page
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping(value="list")
	@RequiresPermissions("SysConstant:list")
	public String list(Model model,HttpServletRequest request,@ModelAttribute SysConstant sysConstant) throws Exception{
		sysConstant.setcOrder(Order.asc("id"));
		model.addAttribute("page", sysConstantService.queryPage(sysConstant));
		return "/sysConstant/sysConstantList";
	}
	
	@RequestMapping(value="update")
	@RequiresPermissions("SysConstant:update")
	@ResponseBody
	public String updateStatus(Model model,HttpServletRequest request,@ModelAttribute(value="entity") SysConstant entity)throws Exception{
		sysConstantService.save(entity);
		return "true";
	}
    
	@Override
	protected Class<SysConstant> getClazz() {
		return SysConstant.class;
	}
	
}
